package com.wcs.spring.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.wcs.spring.entity.ClassInfo;
import com.wcs.spring.mapper.ClassInfoMapper;
import com.wcs.spring.service.ClassInfoService;
import com.wcs.spring.util.PageUtil;

/**
 * <p>
 * Title: Phicomm_[子系统统名]_[模块名]
 * </p>
 * <p>
 * Description: [描述该类概要功能介绍]
 * </p>
 * 
 * @author hexuan2014
 * @version $Revision$ 2015-6-15
 * @author (lastest modification by $Author$)
 * @since 1.0
 */
@Repository(value = "classInfoService")
public class ClassInfoServiceImpl implements ClassInfoService {

	@Resource(name = "classInfoMapper")
	private ClassInfoMapper classInfoMapper;

	@Override
	public List<ClassInfo> queryClassInfoList(ClassInfo classInfo, PageUtil pageUtil) {
		StringBuilder sql = new StringBuilder();
		sql.append(" select * from classInfo u where u.flag=0  ");
		if (null != classInfo.getSchoolId()) {
			sql.append(" and u.schoolId=" + classInfo.getSchoolId());
		}
		sql.append(" order by u.updateTime desc");
		return classInfoMapper.queryClassInfoList(sql.toString());
	}

	@Override
	public List<ClassInfo> queryClassInfoSimple(ClassInfo classInfo) {
		StringBuilder sql = new StringBuilder();
		sql.append(" select id,className from classInfo u where u.flag=0  ");
		if (null != classInfo.getSchoolId()) {
			sql.append(" and u.schoolId=" + classInfo.getSchoolId());
		}
		sql.append(" order by u.className asc ");
		return classInfoMapper.queryClassInfoList(sql.toString());
	}

	@Override
	public int addClassInfo(ClassInfo classInfo) {
		// TODO Auto-generated method stub
		return classInfoMapper.addClassInfo(classInfo);
	}

	@Override
	public void updateClassInfo(ClassInfo classInfo) {
		// TODO Auto-generated method stub
		classInfoMapper.updateClassInfo(classInfo);
	}

	@Override
	public void delClassInfo(ClassInfo classInfo) {
		// TODO Auto-generated method stub
		classInfoMapper.delClassInfo(classInfo);
	}

	@Override
	public ClassInfo queryClassInfoById(Integer id) {
		// TODO Auto-generated method stub
		return classInfoMapper.queryClassInfoById(id);
	}

}
